package cn.edu.scau.cmi.tancuier.adapter;

import java.util.ArrayList;
import java.util.List;

public class StudentSortAdapterOfObject implements StudentSortInterface{

	@Override
	public void sortStudent(List<Student> studentList) {
		List<Student> students = studentList;
		List<Integer> idList = new ArrayList<Integer>();
		for(int i = 0; i < students.size(); i++) {
			idList.add(students.get(i).getId());
		}
		SortUtil sort = new SortUtil();
		sort.sortInt(idList);
		
		Student tmp;
		for(int i = 0; i < idList.size(); i++) {
			for(int j = 0; j < students.size(); j++) {
				if(students.get(j).getId() == idList.get(i)) {
					tmp = students.get(j);
					students.set(j, students.get(i));
					students.set(i, tmp);
				}
			}
		}
		studentList = students;
	}
}
